'use strict';

module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;
  // 连接多个数据库时要在这里指定是哪个数据库
  // const connect = app.mongooseDB.get('db1');

  const UserSchema = new Schema({
    name: { type: String },
    age: { type: Number },
    sex: { type: String },
  });

  // mongoose 通过 model 来操作 mongoDB
  // model('model名', Schema对象, '表名')
  return mongoose.model('User', UserSchema, 'user');
};
